package cn.iocoder.yudao.module.system.controller.admin.a_manuscriptLog;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.a_manuscriptLog.vo.ArticleComparisonReqVO;
import cn.iocoder.yudao.module.system.controller.admin.a_manuscriptLog.vo.ArticleLogPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.a_manuscriptLog.vo.AudioAndVideoLogPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.a_manuscriptLog.vo.PicturesLogPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.a_article.ArticleLogDO;
import cn.iocoder.yudao.module.system.service.a_articleLog.ArticleLogService;
import cn.iocoder.yudao.module.system.service.a_audio_and_video_log.AudioAndVideoLogService;
import cn.iocoder.yudao.module.system.service.a_picturesLog.PicturesLogService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;


@Tag(name = "管理后台 - 稿件管理 - 图片")
@RestController
@RequestMapping("/system/manuscript")
@Validated
public class ManuscriptLogController {

    @Resource
    private ArticleLogService articleLogService;
    @Resource
    private PicturesLogService picturesLogService;
    @Resource
    private AudioAndVideoLogService audioAndVideoLogService;


    @GetMapping("/articleLogPage")
    @Operation(summary = "获得文稿日志分页")
    @PreAuthorize("@ss.hasPermission('system:manuscript:query')")
    public CommonResult<PageResult<ArticleLogDO>> articleLogPage(@Valid ArticleLogPageReqVO pageVO) {
        return success(articleLogService.findPageByRelevanceId(pageVO));
    }

    @GetMapping("/versionComparison")
    @Operation(summary = "对比文稿差异")
    @PreAuthorize("@ss.hasPermission('system:manuscript:query')")
    public CommonResult<Map<Integer,ArticleLogDO>> versionComparison(@Valid ArticleComparisonReqVO articleComparisonReqVO) {
        return success(articleLogService.versionComparison(articleComparisonReqVO));
    }

    @GetMapping("/picturesLogPage")
    @Operation(summary = "获得图片日志分页")
    @PreAuthorize("@ss.hasPermission('system:manuscript:query')")
    public CommonResult<PageResult<PicturesLogPageReqVO>> picturesLogPage(@Valid PicturesLogPageReqVO pageVO) {
        PageResult<PicturesLogPageReqVO> pageResult = picturesLogService.findPageByRelevanceId(pageVO);
        return success(pageResult);
    }

    @GetMapping("/audioAndVideoLogPage")
    @Operation(summary = "获得音视频日志分页")
    @PreAuthorize("@ss.hasPermission('system:manuscript:query')")
    public CommonResult<PageResult<AudioAndVideoLogPageReqVO>> audioAndVideoLogPage(@Valid AudioAndVideoLogPageReqVO pageVO) {
        PageResult<AudioAndVideoLogPageReqVO> pageResult = audioAndVideoLogService.findPageByRelevanceId(pageVO);
        return success(pageResult);
    }


}
